﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GS.Config;
using System.Data;

public partial class usercontrols_subcart : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session[Config.SessionCart] != null)
            {
                DataTable dtCart = (DataTable)Session[Config.SessionCart];
                lblMyCart.Text = "<a href=\"shopping-cart.aspx\">My Cart</a>";
                lblItems.Text = string.Format("{0} Items", dtCart.Rows.Count);
                //Get Price
                decimal price = Convert.ToDecimal(dtCart.Compute("Sum(Price)", ""));
                string[] arrPrice = price.ToString("C").Split('.');
                lblPrice.Text = string.Format("{0}<sup>.{1}</sup>",
                     arrPrice[0], arrPrice[1]);
            }
            else
            {
                lblMyCart.Text = "My Cart";
                lblItems.Text = "is Empty";
                lblPrice.Text =" $0<sup>.00</sup>";
            }
        }
    }
}